import { Injectable } from '@angular/core';
import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { AddHeroComponent } from '@pages/home/add-hero/add-hero.component';

@Injectable({
  providedIn: 'root'
})

export class HeroCanDeactivateGuard implements CanDeactivate<AddHeroComponent> {
  constructor() {}
  canDeactivate(
    component: AddHeroComponent,
    currentRoute: ActivatedRouteSnapshot,
    currentState: RouterStateSnapshot
  ): Observable<boolean|UrlTree>|Promise<boolean|UrlTree>|boolean|UrlTree {
    return component.canDeactivate();
  }
}
